<template>
  <div>
    <comment-message
      @handleReply="handleReply"
      :commentList="comments"
    ></comment-message>
    <comment-area
      @reload="reload"
      :parentMsgId="replyMsgId"
      :replyMsgUsername="replyMsgUsername"
    ></comment-area>
  </div>
</template>

<script>
import CommentMessage from './CommentMessage.vue'
import CommentArea from './CommentArea.vue'

// import { findAllMsg } from 'network/ajax'

export default {
  name: 'Message',
  components: {
    CommentMessage,
    CommentArea,
  },
  data() {
    return {
      comments: [],
      replyMsgId: '',
      replyMsgUsername: '',
      list: [
        {
          id: 12,
          date: '2020-05-31 12:19:43',
          content: '你好啊，太棒了',
          parent_msg_id: null,
          user_id: 5,
          username: 'wangwu',
          parent_msg_username: null,
          children: [],
        },
        {
          id: 11,
          date: '2020-05-31 12:18:55',
          content:
            '的时刻层6666666632\n2面的思考名称看到什么材料是isdafjoisdjiojildsc',
          parent_msg_id: null,
          user_id: 3,
          username: 'zhangsan',
          parent_msg_username: null,
          children: [],
        },
        {
          id: 5,
          date: '2020-05-29 19:09:33',
          content: '发的发射点发吖方吖是发是呵等方5爱的非4阿瑟东方 发',
          parent_msg_id: null,
          user_id: 4,
          username: 'lisi',
          parent_msg_username: null,
          children: [
            {
              id: 13,
              date: '2020-05-31 12:20:12',
              content: '号好好好矮好矮好矮好好',
              parent_msg_id: 5,
              user_id: 6,
              username: 'zhaoliu',
              parent_msg_username: 'lisi',
            },
          ],
        },
        {
          id: 1,
          date: '2020-05-29 19:06:21',
          content: 'fasfdsafas法阿萨德方吖65阿瑟东方5是的发',
          parent_msg_id: null,
          user_id: 1,
          username: 'student',
          parent_msg_username: null,
          children: [
            {
              id: 7,
              date: '2020-05-29 19:29:29',
              content: 'hfhf2h22h222223232',
              parent_msg_id: 6,
              user_id: 1,
              username: 'student',
              parent_msg_username: 'zhaoliu',
            },
            {
              id: 6,
              date: '2020-05-29 19:09:56',
              content: '而离开离开邻居哦i据哦i报价哦v保健品45465',
              parent_msg_id: 4,
              user_id: 6,
              username: 'zhaoliu',
              parent_msg_username: 'mike',
            },
            {
              id: 4,
              date: '2020-05-29 19:09:14',
              content: '发送端非场地萨擦手d5asd32 1dads\r\ndsac十多次ds出错',
              parent_msg_id: 2,
              user_id: 8,
              username: 'mike',
              parent_msg_username: 'lisi',
            },
            {
              id: 3,
              date: '2020-05-29 19:08:56',
              content: '奋发恶法撒打发士大夫士大夫是大 大师傅撒',
              parent_msg_id: 2,
              user_id: 2,
              username: 'teacher',
              parent_msg_username: 'lisi',
            },
            {
              id: 2,
              date: '2020-05-29 19:08:41',
              content: 'fasdfasdf发生的法撒旦飞洒多发点房地产',
              parent_msg_id: 1,
              user_id: 4,
              username: 'lisi',
              parent_msg_username: 'student',
            },
          ],
        },
      ],
    }
  },
  // mounted() {
  //   findAllMsg()
  //     .then(res => {
  //       this.comments = res.data.messages
  //     })
  //     .catch(err => {
  //       console.log(err)
  //       this.$router.push('/500')
  //     })
  // },
  mounted() {
    this.comments = this.list
  },
  methods: {
    handleReply(data) {
      this.replyMsgId = data.msgId
      this.replyMsgUsername = data.msgUsername
    },
    reload() {
      this.$emit('reload')
    },
  },
}
</script>

<style></style>
